/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function getXMLHttpRequest(){
                  var xhr = null;
                  if(window.XMLHttpRequest || window.ActiveXObject){
                        if(window.ActiveXObject){
                                       try{
                                                         xhr = new ActiveXObject("Msxml2.XMLHTTP");
                                                   } catch(e){
                                                                                xhr = new ActiveXObject("Microsoft.XMLHTTP");
                                                                 }
                                        }else{
                                                xhr = new XMLHttpRequest();
                                             }

                        }else{
                                alert("Votre navigateur ne supporte pas XMLHTTPRrequest");
                                                  return null;
                                 }
                         return xhr;
                  }

                function envoyerRequeteEl(form){

                  requeteHttp = getXMLHttpRequest();
                 
                  if(requeteHttp == null)
                       {
                          alert("impossible d'utiliser Ajax sur ce navigateur");
                       }
                       else
                       { 
 
                          requeteHttp.open('POST','ajax/getEleve.php',true);
                              requeteHttp.onreadystatechange=function(){
                                      if(requeteHttp.readyState==4 && requeteHttp.status==200)
                                      {
                                          
                                              recevoirReponseEl(requeteHttp);
                                            
                                      }
                              };

                       requeteHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
                       requeteHttp.send('form='+escape(form));
                       }

                     }
                     
		function recevoirReponseEl(requeteHttp)
		{	  
		 document.getElementById("eleve").length=0;
		 var saisi = requeteHttp.responseText;
                 
                 var reg=/\s\s/i;
			
                 var t=saisi.split(reg);
              
                 var i=t.length;
                 
                 for (var n=0;n<i;n++)
                     {
                    
			var cr=document.createElement("option"); 
                        cr.text=t[n];
                        document.getElementById("eleve").add(cr);
 
                      
                     }	 	 
			return;
		}
		
                
                
        